package liming.tool.handle.net.root.base;

public enum NetType {
    ROOT,
    TCP,
    UDP,
    TU;

    /**
     * 判断是否可以转为指定类型
     */
    public boolean isType(NetType netType) {
        switch (this) {
            case ROOT:
                return netType == this;
            case TCP:
                return netType != UDP;
            case UDP:
                return netType != TCP;
            case TU:
                return true;
            default:
                return false;
        }
    }

    public boolean isRoot() {
        return isType(ROOT);
    }

    public boolean isTcp() {
        return isType(TCP);
    }

    public boolean isUdp() {
        return isType(UDP);
    }

    public boolean isTU() {
        return isType(TU);
    }
}
